#include <iostream>
#include "mysql.hpp"

int main() {
	MySQL mysql;
	mysql.connect("localhost", "test", "123456", "testDB");
	mysql.setAutoCommit(false);

	if (mysql.getAutoCommit()) {
		std::cout << "auto commit ON" << '\n';
	} else {
		std::cout << "auto commit OFF" << '\n';
	}
	mysql.setCharacterSet("utf8");
	std::cout << "当前字符集：" << mysql.getCharacterSet() << '\n';

	std::string sql;
	while (true) {
		std::cout << "mysql>";
		std::getline(std::cin,sql);
		std::cout << mysql.query(sql.c_str()) << '\n';
		
		auto result = mysql.getQueryRestult();
		for (size_t i = 0; i < size(result); ++i) {
			for (size_t j = 0; j < size(result[i]); ++j) {
				std::cout << result[i][j] << " \n"[j == size(result[i]) - 1];
			}
		}
	}
}
